40a93d713872740a3e2a0807c61f961ba3ee7805,src/main/java/com/couchbase/client/core/service/strategies/RoundRobinSelectionStrategy.java,RoundRobinSelectionStrategy,select,#CouchbaseRequest#Endpoint[]#,45

Before Change



        //attempt to find a CONNECTED endpoint at the offset, or try following ones
        for (int i = offset; i < endpointSize; i++) {
            Endpoint endpoint = endpoints[i];
            if (endpoint.isState(LifecycleState.CONNECTED)) {
                return endpoint;
            }
        }

After Change


     * @return the selected endpoint.
     */
    @Override
    public Endpoint select(CouchbaseRequest request, List<Endpoint> endpoints) {
        int endpointSize = endpoints.size();
        //increments skip and prevents it to overflow to a negative value
        skip = Math.max(0, skip+1);
        int offset = skip % endpointSize;

        //attempt to find a CONNECTED endpoint at the offset, or try following ones
        for (int i = offset; i < endpointSize; i++) {
            Endpoint endpoint = endpoints.get(i);
            if (endpoint.isState(LifecycleState.CONNECTED) && endpoint.isFree()) {
                return endpoint;
            }
        }